<template>
  <div>
   <container title="应用分布" class="container">
        <dv-charts :option="option" />
    </container>
  </div>
</template>
<script>
export default {
  name: 'RoseChart',
  data () {
    return {
      option: {}
    }
  },
  methods: {
    createData () {
      const { randomExtend } = this

      this.option = {
        series: [
          {
            type: 'pie',
            radius: '50%',
            roseSort: false,
            data: [
              { name: '估值类', value: randomExtend(40, 70) },
              { name: '政府类', value: randomExtend(20, 30) },
              { name: 'BIM类', value: randomExtend(10, 50) },
              { name: '房产云类', value: randomExtend(5, 20) },
              { name: '其他', value: randomExtend(40, 50) }
            ],
            insideLabel: {
              show: false
            },
            outsideLabel: {
              formatter: '{name} {percent}%',
              labelLineEndLength: 20,
              style: {
                fill: '#fff'
              },
              labelLineStyle: {
                stroke: '#fff'
              }
            },
            roseType: true
          }
        ],
        color: ['#BB4C60', '#3E7EDB', '#CEB140', '#53A7AC', '#3E7DDB']
      }
    },
    randomExtend (minNum, maxNum) {
      if (arguments.length === 1) {
        return parseInt(Math.random() * minNum + 1, 10)
      } else {
        return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10)
      }
    }
  },
  mounted () {
    const { createData } = this

    createData()

    setInterval(createData, 30000)
  }
}
</script>

<style lang="less" scoped>
.container{
  height:311px;
}

</style>
